package cn.ztuo.bitrade.controller.relation;

import cn.ztuo.bitrade.entity.Short;
import cn.ztuo.bitrade.service.RelationService;
import cn.ztuo.bitrade.service.ShortService;
import cn.ztuo.bitrade.util.MessageResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("relation")
@Slf4j
public class RelationController {

    @Autowired
    private RelationService relationService;

    @Autowired
    private ShortService shortService;


    /**
     * 所有空投记录
     * @return
     */
    @RequiresPermissions("relation:shortList")
    @PostMapping("shortList")
    public MessageResult shortList(
            @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
            @RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize,
            @RequestParam(name = "username",required = false) String username,
            @RequestParam(name = "status",required = false,defaultValue = "3") Long status
    ){
       Page<Short> shorts = shortService.getList(pageNum,pageSize,username,status);
       return MessageResult.getSuccessInstance("success",shorts);
    }

}
